package com.hmall.order.web;

import com.hmall.order.dto.OrderDTO;
import com.hmall.order.exception.BaseException;
import com.hmall.order.pojo.Order;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      if (orderId==null){
         throw new BaseException("异常请求错误");
      }
      return orderService.getById(orderId);
   }

   /**
    * 功能描述: 订单提价业务
    * @return :
    * @param order
    */
   @PostMapping
   public String queryOrderById(@RequestBody OrderDTO order) {
      if (order==null){
         throw new BaseException("异常请求错误");
      }
      orderService.creationOrderFrom(order);
      return null;
   }

}
